﻿using System;
using SharpKit.JavaScript;

namespace SharpKit.Onx
{
    /// <summary>
    /// This class implements shared storage according to HTML5 Web Storage standard, http://dev.w3.org/html5/webstorage/ .
    /// https://www.onx.ms/#apiPage/sharedStorage
    /// </summary>
    [JsType(Mode = JsMode.Prototype, Export = false)]
    public class SharedStorage : Emitter
    {
        //No way to new this up
        private SharedStorage()
        { }

        #region Triggers (Events)
        /// <summary>
        /// event when storage changes. The callback function is provided with two arguments: the key that its value has changed and the new value.
        /// </summary>
        public event Action<string, object> Changed
        {
            [JsMethod(Name = "on", InsertArg0 = "'changed'")]
            add
            {
            }
            [JsMethod(Name = "removeListener", InsertArg0 = "'changed'")]
            remove
            {
            }
        }
        #endregion

        #region Properties
        /// <summary>
        /// 
        /// </summary>
        [JsProperty(NativeField = true)]
        public ulong Length { get { return 0; } }
        #endregion

        #region Actions (Methods)
        /// <summary>
        /// 
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        [JsMethod(Name = "key")]
        public JsString Key(ulong index)
        { return null; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        [JsMethod(Name = "getItem")]
        public object GetItem(JsString key)
        { return null; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        /// <param name="data"></param>
        [JsMethod(Name = "setItem")]
        public void SetItem(JsString key, object data)
        { }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="key"></param>
        [JsMethod(Name = "removeItem")]
        public void RemoveItem(JsString key)
        { }

        ///// <summary>
        ///// 
        ///// </summary>
        //[JsMethod(Name = "clear")]
        //public void Clear()
        //{ }
        #endregion
    }
}